import math


class MinStack(object):

    def __init__(self):
        """
        initialize your data structure here.
        """
        self.stack = []
        # 将最小值定义成无穷大
        # self.min_stack = [math.inf]
        self.min_stack = [float("inf")]

    def push(self, val):
        """
        :type val: int
        :rtype: None
        """
        self.stack.append(val)
        self.min_stack.append(min(val, self.min_stack[-1]))

    def pop(self):
        """
        :rtype: None
        """
        self.stack.pop()
        self.min_stack.pop()

    def top(self):
        """
        :rtype: int
        """
        return self.stack[-1]

    def getMin(self):
        """
        :rtype: int
        """
        return self.min_stack[-1]


min_stack = MinStack()
print(min_stack.push(-3))
print(min_stack.push(0))
print(min_stack.push(-2))
print(min_stack.pop())
print(min_stack.top())
print(min_stack.getMin())
